<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  
  <title>使用Git和Github进行代码管理 | 程序小工  | Just do it!</title>
  <meta name="description" content="遇见更好的自己~" />
  <meta name="keywords" content="" />
  <meta name="HandheldFriendly" content="True" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <link rel="shortcut icon" href="/">
  <link rel="alternate" href="/atom.xml" title="程序小工  | Just do it!">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="使用 Git 进行代码版本管理是程序员项目记录和管理的重要途径，并且为便于多设备能够共享代码，进行远程管理是一个比较理想的方式，而 Github 作为全球最大的开源代码管理社区也是非常好的远程仓库选择，并且其提供静态博客域名和服务器，可以直接将仓库作为博客内容源，对于没有购置服务器却希望搭建个人博客的程序员是非常友好的。">
<meta name="keywords" content="github,git">
<meta property="og:type" content="article">
<meta property="og:title" content="使用Git和Github进行代码管理">
<meta property="og:url" content="http://blog.i2arch.tech/2018/04/16/tool-git/index.html">
<meta property="og:site_name" content="程序小工  | Just do it!">
<meta property="og:description" content="使用 Git 进行代码版本管理是程序员项目记录和管理的重要途径，并且为便于多设备能够共享代码，进行远程管理是一个比较理想的方式，而 Github 作为全球最大的开源代码管理社区也是非常好的远程仓库选择，并且其提供静态博客域名和服务器，可以直接将仓库作为博客内容源，对于没有购置服务器却希望搭建个人博客的程序员是非常友好的。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://images2018.cnblogs.com/blog/1049028/201803/1049028-20180318212746038-1187254415.png">
<meta property="og:image" content="https://images2018.cnblogs.com/blog/1049028/201803/1049028-20180318213326726-1484496635.png">
<meta property="og:image" content="https://images2018.cnblogs.com/blog/1049028/201803/1049028-20180318213631372-1010547178.png">
<meta property="og:updated_time" content="2018-08-14T07:59:24.565Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="使用Git和Github进行代码管理">
<meta name="twitter:description" content="使用 Git 进行代码版本管理是程序员项目记录和管理的重要途径，并且为便于多设备能够共享代码，进行远程管理是一个比较理想的方式，而 Github 作为全球最大的开源代码管理社区也是非常好的远程仓库选择，并且其提供静态博客域名和服务器，可以直接将仓库作为博客内容源，对于没有购置服务器却希望搭建个人博客的程序员是非常友好的。">
<meta name="twitter:image" content="https://images2018.cnblogs.com/blog/1049028/201803/1049028-20180318212746038-1187254415.png">
    
  <link href="https://fonts.googleapis.com/css?family=Inconsolata|Titillium+Web" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
  <link href='//cdn.bootcss.com/node-waves/0.7.5/waves.min.css' rel='stylesheet'>
  <link rel="stylesheet" href="/style.css">
  <script>
    function setLoadingBarProgress(num) {
      document.getElementById('loading-bar').style.width=num+"%";
    }
  </script>
</head>

<body>
  <div id="loading-bar-wrapper">
  <div id="loading-bar"></div>
</div>


  <script>setLoadingBarProgress(20)</script>
  <header class="l_header">
	<div class='wrapper'>
		<div class="nav-main container container--flex">
			<a class="logo flat-box" href='/' >
				程序小工  | Just do it!
			</a>
			<div class='menu'>
				<ul class='h-list'>
					
						<li>
							<a class='flat-box nav-home' href='/'>
								<i class='icon icon-list2'></i>
								首页
							</a>
						</li>
					
						<li>
							<a class='flat-box nav-archives' href='/archives'>
								<i class='icon icon-bookmark'></i>
								归档
							</a>
						</li>
					
						<li>
							<a class='flat-box nav-about' href='/about'>
								<i class='icon icon-user'></i>
								关于
							</a>
						</li>
					
				</ul>
				<div class='underline'></div>
			</div>
			
				<div class="m_search">
					<form name="searchform" class="form u-search-form">
						<input type="text" class="input u-search-input" placeholder="Search" />
						<span class="icon icon-search"></span>
					</form>
				</div>
			
			<ul class='switcher h-list'>
				
					<li class='s-search'><a href='javascript:void(0)'><span class="icon icon-search flat-box"></span></a></li>
				
				<li class='s-menu'><a href='javascript:void(0)'><span class="icon icon-menu flat-box"></span></a></li>
			</ul>
		</div>

		<div class='nav-sub container container--flex'>
			<a class="logo" class="flat-box" href='javascript:void(0)'>
				Word of Forks
			</a>

			<ul class='switcher h-list'>
				<li class='s-comment'><a href='javascript:void(0)'><span class="icon icon-chat_bubble_outline flat-box"></span></a></li>
				<li class='s-top'><a href='javascript:void(0)'><span class="icon icon-arrow_upward flat-box"></span></a></li>
				<li class='s-toc'><a href='javascript:void(0)'><span class="icon icon-format_list_numbered flat-box"></span></a></li>
			</ul>
		</div>
	</div>
</header>
<aside class="menu-phone">
	<nav>
		
			<a href="/" class="nav-home nav">
				首页
			</a>
		
			<a href="/archives" class="nav-archives nav">
				归档
			</a>
		
			<a href="/about" class="nav-about nav">
				关于
			</a>
		
	</nav>
</aside>

    <script>setLoadingBarProgress(40);</script>
  <div class="l_body">
    <div class='container clearfix'>
      <!-- 左侧内容 -->
      <div class='l_main'>
        <article id="post-tool-git"
  class="post white-box article-type-post"
  itemscope itemprop="blogPost">
	<section class='meta'>

	<h2 class="title">
  	<a href="/2018/04/16/tool-git/">
    	使用Git和Github进行代码管理
    </a>
	</h2>

	<div class="pagenav">
		<time>
			2018-04-16
		</time>

		
    
    <div class='cats'>
        <i class="icon icon-bookmark"></i>
        <a href="/categories/Git/">Git</a>
    </div>


		
			<div class="pagetags">
				<i class="icon icon-price-tag" style="margin-right: 2px;"></i>
				
					<a href="/tags/github/" style="margin-left: 3px;">
						github
					</a>
				
					<a href="/tags/git/" style="margin-left: 3px;">
						git
					</a>
				
			</div>
			
	</div>
	</section>

	
	<section class="toc-wrapper"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-安装-git"><span class="toc-text"> 1、安装 Git</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-生成-ssh-秘钥"><span class="toc-text"> 2、生成 ssh 秘钥</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-查看公钥信息"><span class="toc-text"> 3、查看公钥信息</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-放到-github-网站上"><span class="toc-text"> 4、放到 github 网站上</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-测试秘钥是否能够成功访问-github-网站"><span class="toc-text"> 5、测试秘钥是否能够成功访问 github 网站</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#参考资料"><span class="toc-text"> 参考资料：</span></a></li></ol></section>
	

	<section class="article typo">
		<div class="article-entry" itemprop="articleBody">
				<span class="zhaiyao">[摘要]</span>
			<p>使用 Git 进行代码版本管理是程序员项目记录和管理的重要途径，并且为便于多设备能够共享代码，进行远程管理是一个比较理想的方式，而 Github 作为全球最大的开源代码管理社区也是非常好的远程仓库选择，并且其提供静态博客域名和服务器，可以直接将仓库作为博客内容源，对于没有购置服务器却希望搭建个人博客的程序员是非常友好的。</p>
<a id="more"></a>
<h2 id="1-安装-git"><a class="markdownIt-Anchor" href="#1-安装-git"></a> 1、安装 Git</h2>
<p>官网下载地址：<a href="https://git-scm.com/downloads" target="_blank" rel="noopener">下载</a></p>
<p>学习教程:</p>
<ul>
<li>
<p>官方手册：<a href="https://git-scm.com/docs" target="_blank" rel="noopener">前往</a></p>
</li>
<li>
<p>Pro Git: <a href="https://git-scm.com/book/zh/v2" target="_blank" rel="noopener">查看</a></p>
</li>
</ul>
<h2 id="2-生成-ssh-秘钥"><a class="markdownIt-Anchor" href="#2-生成-ssh-秘钥"></a> 2、生成 ssh 秘钥</h2>
<p><code>ssh-keygen</code></p>
<p>中间出现提示进行设置 ssh 秘钥的存放地址，此处可直接回车，放到默认的存储位置<code>/c/Users/Administrator/.ssh/</code></p>
<p><img src="https://images2018.cnblogs.com/blog/1049028/201803/1049028-20180318212746038-1187254415.png" alt=""></p>
<h2 id="3-查看公钥信息"><a class="markdownIt-Anchor" href="#3-查看公钥信息"></a> 3、查看公钥信息</h2>
<p><code>cat /c/Users/Administrator/.ssh/id_rsa.pub</code></p>
<p><img src="https://images2018.cnblogs.com/blog/1049028/201803/1049028-20180318213326726-1484496635.png" alt=""></p>
<h2 id="4-放到-github-网站上"><a class="markdownIt-Anchor" href="#4-放到-github-网站上"></a> 4、放到 github 网站上</h2>
<p>（设置秘钥入口：<a href="https://github.com/settings/keys" target="_blank" rel="noopener">传送门</a>）</p>
<h2 id="5-测试秘钥是否能够成功访问-github-网站"><a class="markdownIt-Anchor" href="#5-测试秘钥是否能够成功访问-github-网站"></a> 5、测试秘钥是否能够成功访问 github 网站</h2>
<p><code>ssh -T git@github.com</code><br>
中间需要手动输入进行确认</p>
<p><img src="https://images2018.cnblogs.com/blog/1049028/201803/1049028-20180318213631372-1010547178.png" alt=""></p>
<p>【问题调整】：</p>
<p>如果执行上述命令时，出现以下错误提示</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Hi username! You<span class="string">'ve successfully authenticated, but GitHub does not</span></span><br><span class="line"><span class="string">provide shell access.</span></span><br></pre></td></tr></table></figure>
<p>则需要再对ssh配置文件进行配置<code>~/.ssh/config</code> [.ssh的目录以自己安装时设置的目录为准]</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Host github.com</span><br><span class="line">Hostname ssh.github.com</span><br><span class="line">Port 443</span><br></pre></td></tr></table></figure>
<p>设置完成后再执行上述命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_10_centos i2arch]<span class="comment"># ssh -T git@github.com</span></span><br><span class="line">The authenticity of host <span class="string">'[ssh.github.com]:443 ([192.xx.xx.123]:443)'</span> can<span class="string">'t be established.</span></span><br><span class="line"><span class="string">RSA key fingerprint is SHA256xxxxxxxxxxxxxxxxxxxxxxxxLviKw6E5SY8.</span></span><br><span class="line"><span class="string">RSA key fingerprint is MD5:1xxxxxxxxxxxxxxxxxxxxxxxxxxxxd:eb:df:a6:48.</span></span><br><span class="line"><span class="string">Are you sure you want to continue connecting (yes/no)? yes</span></span><br><span class="line"><span class="string">Warning: Permanently added '</span>[ssh.github.com]:443,[192.xx.xx.123]:443<span class="string">' (RSA) to the list of known hosts.</span></span><br><span class="line"><span class="string">Hi zqunor! You'</span>ve successfully authenticated, but GitHub does not provide shell access.</span><br></pre></td></tr></table></figure>
<p>则证明已经可以使用git访问github，后续即可直接进行项目管理</p>
<h2 id="参考资料"><a class="markdownIt-Anchor" href="#参考资料"></a> 参考资料：</h2>
<p><a href="https://help.github.com/articles/using-ssh-over-the-https-port/" target="_blank" rel="noopener">Github Help</a></p>

		</div>

		
			<div class="art-item-footer">
					
						<span class="art-item-left"><i class="icon icon-chevron-thin-left"></i> <a href="/2018/04/16/tool-git-remote-add/" rel="prev" title="Git项目管理--将现有项目提交到空仓库">
							Git项目管理--将现有项目提交到空仓库
						</a>上一篇文章</span>
					
					
						<span class="art-item-right">下一篇文章：<a href="/2018/04/16/php-email/" rel="next"  title="PHP扩展功能--发送邮件">
							PHP扩展功能--发送邮件
						</a><i class="icon icon-chevron-thin-right"></i></span>
					
			</div>
		

		
			

    <div class="recommended_posts">
        <h3>推荐文章</h3>
        <ul>
            
                <li><a href="http://blog.i2arch.tech/2018/04/26/composer-image/">Composer设置国内镜像</a></li>
            
                <li><a href="http://blog.i2arch.tech/2018/04/16/tool-git-remote-add/">Git项目管理--将现有项目提交到空仓库</a></li>
            
                <li><a href="http://blog.i2arch.tech/2018/04/16/php-email/">PHP扩展功能--发送邮件</a></li>
            
                <li><a href="http://blog.i2arch.tech/2018/04/16/php-curl/">PHP扩展功能--cURL</a></li>
            
        </ul>
    </div>


		
	</section>

	

</article>
<script>
	window.subData = {
		title: '使用Git和Github进行代码管理',
		tools: true
	}
</script>

      </div>

      <!-- 右侧边栏组件 -->
      <aside class='l_side'>
        
      </aside>

      <div class="gotop">
          
    <a href='javascript:void(0)'>
        <i class="icon icon-arrow_upward flat-box">
        </i>
    </a>

      </div>
      <script>setLoadingBarProgress(60);</script>
    </div>
  </div>
  <footer id="footer" class="clearfix">

	<div class="social-wrapper">
  	
      
        <a href="https://github.com/zqunor" class="social github"
          target="_blank" rel="external">
          <span class="icon icon-github"></span>
        </a>
      
        <a href="https://www.cnblogs.com/zqunor" class="social zhihu"
          target="_blank" rel="external">
          <span class="icon icon-zhihu"></span>
        </a>
      
        <a href="/atom.xml" class="social rss"
          target="_blank" rel="external">
          <span class="icon icon-rss"></span>
        </a>
      
    
  </div>
  <div>Theme <a href='https://github.com/stkevintan/hexo-theme-material-flow' class="codename">MaterialFlow</a>  Powered by<a href="https://blog.i2arch.tech/" target="_blank">程序小工</a>.</div>

</footer>

  <script>setLoadingBarProgress(80);</script>
  

    <script src="//apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src='//cdn.bootcss.com/node-waves/0.7.5/waves.min.js'></script>
    <script src="//cdn.bootcss.com/scrollReveal.js/3.3.2/scrollreveal.min.js"></script>
    <script src="/js/jquery.fitvids.js"></script>
      <script>
        var GOOGLE_CUSTOM_SEARCH_API_KEY = "";
        var GOOGLE_CUSTOM_SEARCH_ENGINE_ID = "";
        var ALGOLIA_API_KEY = "";
        var ALGOLIA_APP_ID = "";
        var ALGOLIA_INDEX_NAME = "";
        var AZURE_SERVICE_NAME = "";
        var AZURE_INDEX_NAME = "";
        var AZURE_QUERY_KEY = "";
        var BAIDU_API_ID = "fca5b83cf69f752ddc96a61ef64a3659";
        var SEARCH_SERVICE = "hexo";
        var ROOT = "/" || "/";
        if (!ROOT.endsWith('/')) ROOT += '/';
      </script>
      <script src="/js/search.js"></script>
        <script src="/js/app.js"></script>
  <script>setLoadingBarProgress(100);</script>
</body>
</html>
